import Vue from 'vue'
import Router from "vue-router";
Vue.use(Router)
const router = new Router({
  routes: [
    {
      path: '/welcome',
      name: 'welcome',
      component: () => import(/* webpackChunkName:'welcome' */ '../views/Welcome/Index.vue'),
      redirect: '/modules',
      children: [
        {
          path: '/modules',
          name: 'modules',
          component: () => import(/* webpackChunkName:'Modules' */ '../views/Welcome/Modules.vue'),
        },
        {
          path: '/apps',
          name: 'apps',
          component: () => import(/* webpackChunkName:'Apps' */ '../views/Welcome/Apps.vue'),
        },
      ]
    },
    {
      path: "/empower",
      name: "empower",
      component: () => import('../views/empower/index.vue')
    },
    {
      path: "/index",
      name: "index",
      component: () => import('../views/Nav.vue'),
      redirect: '/default',
      children: [
        {
          path: "/jklb",
          name: "jklb",
          component: () => import("../views/JianKongLieBiao/Index.vue"),
          meta: {
            title: '云巡查',
            renovate: true,
          }
        },
        {
          path: '/default',
          name: 'default',
          component: () => import('../views/HomeIndex/index.vue'),
          meta: {
            title: '首页'
          }
        },
        {
          path: '/ycjc',
          name: 'ycjc',
          component: () => import('../views/DustMonitor/DustMonitor.vue'),
          meta: {
            title: '扬尘监测',
          }
        },
        {
          path: '/zdjj',
          name: 'zdjj',
          component: () => import('../views/ZhanDaoJingYing/Index.vue'),
          meta: {
            title: '占道经营',
            renovate: true,
          }
        },
        {
          path: "/zhgd",
          name: "zhgd",
          component: () => import("../views/ZhiHuiGongDi/Index.vue"),
          meta: {
            title: '智慧工地',
            renovate: true,
          }
        },
        {
          path: "/ljxq",
          name: "ljxq",
          component: () => import("../views/LaoJiuXiaoQuGaiZao/Index.vue"),
          meta: {
            title: '老旧小区改造'
          }
        },
        {
          path: "/mtbs",
          name: "mtbs",
          component: () => import("../views/MenTouBaoShen/Index.vue"),
          meta: {
            title: '门头报审'
          }
        },
        {
          path: "/zhjx",
          name: "zhjx",
          component: () => import("../views/ZhiHuiJIeXiang/index.vue"),
          meta: {
            title: '智慧街乡'
          }
        },
        {
          path: "/bjdt",
          name: "bjdt",
          component: () => import("../views/BuJianDiTu/index.vue"),
          meta: {
            title: '部件地图'
          }
        },
        {
          path: "/jxcs",
          name: "jxcs",
          component: () => import("../views/JieXiangChuiShao/Index.vue"),
          meta: {
            title: '街乡吹哨'
          }
        },

      ]
    },

    // 北营

    {
      path: "/by",
      name: "by",
      component: () => import('../views/Nav.vue'),
      redirect: '/by/default',
      children: [
        {
          path: '/by/default',
          component: () => import('../views/HomeIndex/index.vue'),
          meta: {
            title: '首页'
          }
        },
        {
          path: "/by/jklb",
          component: () => import("../views/JianKongLieBiao/Index.vue"),
          meta: {
            title: '云巡查',
            renovate: true,
          }
        },

        {
          path: '/by/ycjc',
          component: () => import('../views/DustMonitor/DustMonitor.vue'),
          meta: {
            title: '扬尘监测',
          }
        },
        {
          path: '/by/zdjj',
          component: () => import('../views/ZhanDaoJingYing/Index.vue'),
          meta: {
            title: '占道经营',
            renovate: true,
          }
        },
        {
          path: "/by/zhgd",
          component: () => import("../views/ZhiHuiGongDi/Index.vue"),
          meta: {
            title: '智慧工地',
            renovate: true,
          }
        },
        {
          path: "/by/ljxq",
          component: () => import("../views/LaoJiuXiaoQuGaiZao/Index.vue"),
          meta: {
            title: '老旧小区改造'
          }
        },
        {
          path: "/by/mtbs",
          component: () => import("../views/MenTouBaoShen/Index.vue"),
          meta: {
            title: '门头报审'
          }
        },
        {
          path: "/by/zhjx",
          component: () => import("../views/ZhiHuiJIeXiang/index.vue"),
          meta: {
            title: '智慧街乡'
          }
        },
        {
          path: "/by/bjdt",
          component: () => import("../views/BuJianDiTu/index.vue"),
          meta: {
            title: '部件地图'
          }
        },

      ]
    },


    // 市场监督管理
    {
      path: "/scjd",
      name: "scjd",
      component: () => import('../views/Nav.vue'),
      redirect: '/scjd/index',
      children: [
        {
          path: '/scjd/index',
          component: () => import("../views/ShiChangJianDu/Index.vue"),
          meta: {
            title: '市场监督'
          }
        },
      ]
    },

    // 城管指挥中心
    {
      path: "/cg",
      name: "cg",
      component: () => import('../views/Nav.vue'),
      redirect: '/cg/default',
      children: [
        {
          path: '/cg/default',
          component: () => import('../views/HomeIndex/index.vue'),
          meta: {
            title: '首页'
          }
        },
        {
          path: "/cg/jklb",
          component: () => import("../views/JianKongLieBiao/Index.vue"),
          meta: {
            title: '云巡查',
            renovate: true,
          }
        },
        {
          path: '/cg/zdjj',
          component: () => import('../views/ZhanDaoJingYing/Index.vue'),
          meta: {
            title: '占道经营',
            renovate: true,
          }
        },
        {
          path: '/cg/ycjc',
          component: () => import('../views/DustMonitor/DustMonitor.vue'),
          meta: {
            title: '扬尘监测',
          }
        },
        {
          path: "/cg/mtbs",
          component: () => import("../views/MenTouBaoShen/Index.vue"),
          meta: {
            title: '门头报审'
          }
        },
      ]
    },
    {
      path: "*",
      redirect: "/index"
    }
  ]
});
router.beforeEach((to, from, next) => {//beforeEach是router的钩子函数，在进入路由前执行
  if (to.path.includes('/by')) {//判断是否有标题
    document.title = '北营街道综合行政执法智慧服务平台'
  } else if (to.path.includes('/cg')) {
    document.title = '小店区城管指挥中心'
  } else {
    document.title = '长子县综合执法监管平台'
  }
  next()  //执行进入路由，如果不写就不会进入目标页
})
export default router